package com.dk.hi.gui.comp;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.geom.Circle;
import org.newdawn.slick.state.StateBasedGame;

import com.dk.hi.core.Block;
import com.dk.hi.core.Settings;
import com.dk.hi.gui.MapActor;

public class MapActorMenu extends GraphicComponent {
	private static final int TALK = 0;
	private static final int DESCRIBE = 1;
	private static final int TRADE = 2;

	private int x;
	private int y;

	public MapActorMenu(MapActor source) {
		this.x = source.getX() + Block.SIZE / 2;
		this.y = source.getY() + Block.SIZE / 2;
	}

	@Override
	protected void renderComponent(Graphics g) throws SlickException {
		final int menuRadius = 36;
		final int itemRadius = 16;
		final int ox = this.x;
		final int oy = this.y;

		if (Settings.DEBUG_ENTITIES) {
			Circle c = new Circle(ox, oy, menuRadius);
			g.draw(c);

			Circle talkC = new Circle(ox - menuRadius / 2, oy - computeTheorem(menuRadius / 2, menuRadius), itemRadius);
			g.fill(talkC);

			Circle descC = new Circle(ox + menuRadius / 2, oy - computeTheorem(menuRadius / 2, menuRadius), itemRadius);
			g.fill(descC);

			Circle tradeC = new Circle(ox + menuRadius, oy, itemRadius);
			g.fill(tradeC);

			Circle specialC = new Circle(ox + menuRadius / 2, oy + computeTheorem(menuRadius / 2, menuRadius), itemRadius);
			g.fill(specialC);
		}
	}

	@Override
	protected void updateComponent(GameContainer container, StateBasedGame game, int delta) throws SlickException {
		// TODO Auto-generated method stub

	}

	private int computeTheorem(int a, int c) {
		return Double.valueOf(Math.sqrt((c * c) - (a * a))).intValue();
	}
}
